import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 *Simulate a deck of cards.
 *
 *@author Jeff Friesen
 */
public class Deck
{
	private Card[] cards = new Card[]
	{
		Card.ACE_OF_CLUBS,
		Card.TWO_OF_CLUBS,
		Card.THREE_OF_CLUBS,
		Card.FOUR_OF_CLUBS,
		Card.FIVE_OF_CLUBS,
		Card.SIX_OF_CLUBS,
		Card.SEVEN_OF_CLUBS,
		Card.EIGHT_OF_CLUBS,
		Card.NINE_OF_CLUBS,
		Card.TEN_OF_CLUBS,
		Card.JACK_OF_CLUBS,
		Card.QUEEN_OF_CLUBS,
		Card.KING_OF_CLUBS,
		Card.ACE_OF_DIAMONDS,
		Card.TWO_OF_DIAMONDS,
		Card.THREE_OF_DIAMONDS,
		Card.FOUR_OF_DIAMONDS,
		Card.FIVE_OF_DIAMONDS,
		Card.SIX_OF_DIAMONDS,
		Card.SEVEN_OF_DIAMONDS,
		Card.EIGHT_OF_DIAMONDS,
		Card.NINE_OF_DIAMONDS,
		Card.TEN_OF_DIAMONDS,
		Card.JACK_OF_DIAMONDS,
		Card.QUEEN_OF_DIAMONDS,
		Card.KING_OF_DIAMONDS,
		Card.ACE_OF_HEARTS,
		Card.TWO_OF_HEARTS,
		Card.THREE_OF_HEARTS,
		Card.FOUR_OF_HEARTS,
		Card.FIVE_OF_HEARTS,
		Card.SIX_OF_HEARTS,
		Card.SEVEN_OF_HEARTS,
		Card.EIGHT_OF_HEARTS,
		Card.NINE_OF_HEARTS,
		Card.TEN_OF_HEARTS,
		Card.JACK_OF_HEARTS,
		Card.QUEEN_OF_HEARTS,
		Card.KING_OF_HEARTS,
		Card.ACE_OF_SPADES,
		Card.TWO_OF_SPADES,
		Card.THREE_OF_SPADES,
		Card.FOUR_OF_SPADES,
		Card.FIVE_OF_SPADES,
		Card.SIX_OF_SPADES,
		Card.SEVEN_OF_SPADES,
		Card.EIGHT_OF_SPADES,
		Card.NINE_OF_SPADES,
		Card.TEN_OF_SPADES,
		Card.JACK_OF_SPADES,
		Card.QUEEN_OF_SPADES,
		Card.KING_OF_SPADES,
	};
	private List<Card> deck;
	/**
	 *Create a <code>Deck</code> of 52 <code>Card</code> objects.
	 *Shuffle these objects.
	 *
	 */
	public Deck()
	{
		deck = new ArrayList<Card>();
		for(int i = 0; i < cards.length; i++)
		{
			deck.add(cards[i]);
			cards[i] = null;
		}
		Collections.shuffle(deck);
	}
	/**
	 *Deal the <code>Deck</code>'s top <code>Card</code> object.
	 *
	 *@return the <code>Card</code> object at the top of the
	 *<code>Deck</code>
	 */
	public Card deal()
	{
		return deck.remove(0);
	}
	/**
	 *Return an indicator of whether or not the <code>Deck</code> is empty.
	 *
	 *@return true if the <code>Deck</code> contains no <code>Card</code>
	 *objects;otherwise,false
	 */
	public boolean isEmpty()
	{
		return deck.isEmpty();
	}
	/**
	 *Put back a <code>Card</code> at the bottom of the <code>Deck</code>.
	 *
	 *@param card <code>Card</code> object being put back
	 */
	public void putBack(Card card)
	{
		deck.add(card);
	}
	/**
	 *Shuffle the <code>Deck</code>.
	 */
	public void shuffle()
	{
		Collections.shuffle(deck);
	}

}
